package org.com.blbl.ChargeRate;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class ChargeRateMapper extends Mapper<LongWritable, Text, Text, Text> {

    private Text userId = new Text();
    private Text likeCountAndViewCount = new Text();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws InterruptedException, IOException {
        String[] fields = value.toString().split(",");
        userId.set(fields[1]);
        // 这里我们简单地将点赞数和播放数拼接成一个字符串，用逗号分隔
        likeCountAndViewCount.set(fields[5] + "," + fields[6]);
        context.write(userId, likeCountAndViewCount);
    }

}
